package com.kaiyidiannao.data;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import com.kaiyidiannao.main.R;
import com.kaiyidiannao.model.bean.*;
import com.kaiyidiannao.widget.MyListview2;

import java.io.Serializable;
import java.util.*;

/**
 * Created by 闯儿 on 14-4-2.
 */
public class DataCenter extends Observable {
    public static int backgroundTipBt = 0;
    public static int backgroundTip = 0;
    public static int index = 0;
    public static int index1 = 0;
    public static int index2 = 0;
    public static int index3 = 0;
    public static int index4 = 0;
    public static int index5 = 0;
    public static int index6 = 0;
    public static int index7 = 4;
    public static int index8 = 0;
    public static int position;
    public static String search;
    public static int message_position = 0;
    public static int myfav_position = 0;
    public static int mypub_position = 0;
    public static int myjoin_position = 0;
    public static int mybidd_position = 0;
    public static int gather_position = 0;
    public static int day_position = 0;
    public static int car_position = 0;
    public static int car_search_position = 0;
    public static int house_position = 0;
    public static int house_search_position = 0;
    public static int typeid;
    public static int tip = 0;//判断listView
    public static Context context = null;
    public static DataCenter instance = null;
    public static UserBean userBean = new UserBean();
    public static String successFlag = "1";
    public static String failedFlag = "0";
    public static String code = "";
    public static String msg = "";
    public static int flags1 = -1;
    public static int flags2 = -1;
    public static int flags3 = -1;
    public static int flags4 = -1;
    public static int count;
    public static String password;
    public static int o = 0;
    public static String userid;
    public static String brandName;
    public static boolean isLoad = false;
    //    软件版本
    public static String version;
    //二维码地址
    public static String address;
    public static Bitmap tempBitmap;

    public static HashMap<Integer, View> lmap = new HashMap<Integer, View>();
    public static HashMap<Integer, View> lmap1 = new HashMap<Integer, View>();

    public static ArrayList<?> targetlist = new ArrayList<Object>();

    // listview默认常量（当前默认页数，默认每页数量）
    public static final int LISTVIEW_DEFAULT_PAGE = 1;
    public static final int LISTVIEW_BAIDU_DEFAULT_PAGE = 0;
    public static final int LISTVIEW_DEFAULT_COUNT = 1;
    public static int PAGE = 0;

    // 日志常量
    public static String LOG_ERROR = "[kaiyiapp-ERROR]";
    public static String LOG_INFO = "[kaiyiapp-INFO]";

    public static final String DIVIDED_SYMBOLS = "\\|";

    //置顶滚动栏需要的参数
    public static moduleFlag rolling_current_module_id;
    public static int rolling_tour_module_id; //凑对去模块区分

    public static enum moduleFlag {
        none,
        daydaycoupon, aution, tour_line,
        foodpalace, buystreet, play, secondhandcar, SecondHandHouse, messageInfo
    }


    //写死的经纬度
    public static Double nowLongitude ;
    public static Double nowLatitude;
    public static String currentAddress;


    public static String resultes = "";//删除或者添加成功或失败的标示
    //    我的加入
    public static ArrayList<MyJoinBean> myJoinBeans = new ArrayList<MyJoinBean>();
    public static MyListview2 myJoinPeopleListview;
    public static ArrayList<MyJoinPeopleBean> myJoinPeopleBeans = new ArrayList<MyJoinPeopleBean>();
    // ************DayDayConpon天天里面的数据************
    public static ArrayList<DaydayCouponBean> daydayCouponBeanList = new ArrayList<DaydayCouponBean>(); // 天天惠列表数据
    public static ArrayList<DaydayCouponBean> daydayCouponTopBeansList = new ArrayList<DaydayCouponBean>();// 天天惠列表-置顶滚动栏数据
    public static ArrayList<DaydayCouponBean> shoppingCarList = new ArrayList<DaydayCouponBean>(); //购物车
    public static DaydayCouponBean daydayCouponBean = null; // 天天惠详情
    public static String orderid = ""; //购物车订单号码
    //    美食城，十字街，完了住
    public static ArrayList<PlayBean> foodPalaceList = new ArrayList<PlayBean>();
    public static ArrayList<SinaPoi> sinaPoiList = new ArrayList<SinaPoi>(); // 测试新浪接口
    // ************Play玩乐住,美食街FoodPalace,石子街里面的数据************
    public static ArrayList<PlayBean> playBeanList = new ArrayList<PlayBean>(); // 玩乐住列表数据
    public static ArrayList<PlayBean> playTopBeansTopList = new ArrayList<PlayBean>();// 玩乐住列表-置顶滚动栏数据
    //    拍拍乐
    public static AuctionDetail auctionShow  = null;
    public static ArrayList<Auction> auctionArrayList = new ArrayList<Auction>();
    public static ArrayList<Auction> auctionTopList = new ArrayList<Auction>();
    //二手车
    public static ArrayList<SecondHandCar> secondHandCar = new ArrayList<SecondHandCar>();
    public static ArrayList<SecondHandCar> secondHandCarTop = new ArrayList<SecondHandCar>();
    public static final int secondHandCar_category_id = 64;
    public static ArrayList<SecondHandCar> secondHandCarShow = new ArrayList<SecondHandCar>();
    //二手房
    public static ArrayList<SecondHandHouse> secondHandHouse = new ArrayList<SecondHandHouse>();
    public static ArrayList<SecondHandHouse> secondHandHouseTop = new ArrayList<SecondHandHouse>();
    public static ArrayList<SecondHandHouse> secondHandHouses = new ArrayList<SecondHandHouse>();
    public static final int secondHandHouse_category_id = 65;
    public static ArrayList<SecondHandHouse> secondHandHouseShow = new ArrayList<SecondHandHouse>();
    //凑对去
    public static ArrayList<TourBean> tourList = new ArrayList<TourBean>();
    public static ArrayList<TourBean> tourTopList = new ArrayList<TourBean>();
    public static ArrayList<Comment> tourCommentList = new ArrayList<Comment>();
    public static boolean tourPublishFlag = true;
    //我的关注
    public static ArrayList<FocusOnBean> focusOnBeans = new ArrayList<FocusOnBean>();
    // ************信息框数据************
    public static ArrayList<MessageBean> messageInfoList = new ArrayList<MessageBean>(); // 信息框列表数据
    public static ArrayList<MessageBean> messageInfoTop = new ArrayList<MessageBean>(); // 信息框置顶滚动
    public static ArrayList<MessageBean> messageInfoShowList = new ArrayList<MessageBean>();
    //注册
    public static ArrayList<UserBean> userRegister = new ArrayList<UserBean>();

    //加盟
    public static ArrayList<JoinInBean> joinInBeans = new ArrayList<JoinInBean>();

    //编辑用户
    public static ArrayList<UserBean> userLogin = new ArrayList<UserBean>();


    //用户详情
    public static ArrayList<UserBean> userBeans = new ArrayList<UserBean>();
    public static ArrayList<OrderBean> orderBeans = new ArrayList<OrderBean>();

    //我的订单
    public static ArrayList<Order> orders = new ArrayList<Order>();

    //我的发布--拍拍乐
    public static ArrayList<Auction> beansAuction = new ArrayList<Auction>();

    public static ArrayList status = new ArrayList();

    //我的发布--二手车
    public static ArrayList<SecondHandCar> beansCar = new ArrayList<SecondHandCar>();

    //我的发布--二手房
    public static ArrayList<SecondHandHouse> beansHouse = new ArrayList<SecondHandHouse>();

    //我的发布--召集
    public static ArrayList<TourBean> beansGather = new ArrayList<TourBean>();

    //我的发布--召集
    public static ArrayList<TourBean> beansSmall = new ArrayList<TourBean>();
    public static ArrayList<JoinConstact> joinConstacts = new ArrayList<JoinConstact>();

    //我的竞价
    public static ArrayList<Auction> auctions = new ArrayList<Auction>();
    public static TreeMap<Integer, View> shoppingCarMap = new TreeMap<Integer, View>();

    //页面详情用的bean
    public static Serializable bean;

    //我的收藏和点赞的catid全是固定的
    public static final int CATID_daydaycoupon = 4; //天天惠
    public static final int CATID_acution = 66; //拍拍乐
    public static final int CATID_SECOND_CAR = 64; //二手车
    public static final int CATID_SECOND_HOUSE = 65;//二手房
    public static final int CATID_MESSAGE_INF = 56;//信息框
    public static final int CATID_FOOD_PALACE = 16;//美食城
    public static final int CATID_BUY_STREAT = 32;//石子街
    public static final int CATID_PLAY = 49;//玩乐住

    public static final int CATID_TOUR_SMALL_NOTE = 54;//凑对去-微记
    public static final int CATID_TOUR_GATHER = 53;//凑对去-召集
    public static final int CATID_TOUR_LINE = 55;//凑对去-旅游线路


    //天天惠商品分类，对应的cati编号
    public static final int[] daydaycoupon_category_id = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
    public static final int[] getDaydaycoupon_category_img = {
            R.drawable.catagory_00_selector,
            R.drawable.catagory_01_selector,
            R.drawable.catagory_02_selector,
            R.drawable.catagory_03_selector,
            R.drawable.catagory_04_selector,
            R.drawable.catagory_05_selector,
            R.drawable.catagory_06_selector,
            R.drawable.catagory_07_selector,
            R.drawable.catagory_08_selector,
            R.drawable.catagory_09_selector,
            R.drawable.catagory_10_selector,
            R.drawable.catagory_11_selector
    };
    //美食城分类，对应的id编号
    public static final int[] foodPalace_category_id = { 16,17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};

    public static final int[] commmon_category_img = {
            R.drawable.catagory_00_selector,
            R.drawable.catagory_20_selector
    };
    //石子街分类，对应的id编号
    public static final int[] buystreet_category_id = {32,33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48};
    //玩乐住分类，对应的id编号
    public static final int[] play_category_id = {49, 50, 51, 52};

    //拍拍乐分类，对应的id编号
    public static final int[] pat_category_id = {66, 67, 68, 69, 70, 71};
    //凑队去分类，对应的id编号
    public static final int[] tour_category_id = {53, 55, 54};//不要东这个顺序,依次是 凑对去-召集, 凑对去-旅游线路， 凑对去-微记，
    //信息矿分类，对应的id编号
    public static final int[] messageInfo_id = {56, 57, 58, 59, 60, 61, 62, 63};
    //我的收藏对应编号
    public static final int[] myfacorites_id = {4, 66, 65, 64, 56, 16, 32, 49};


    //www.3tixa.com:8086/kaiyi
    //http://125.76.161.223:8086/kaiyi/
    //public static final String SERVER_ADDRESS = "http://125.76.161.223:8086/kaiyi/";
    public static final String SINA_OPEN_ADDRESS_INTERFECE = "https://api.weibo.com/2/location/pois/search/by_geo.json";
    //
//   public static final String SERVER_ADDRESS = "http://192.168.28.139:8080/kaiyi/";
    public static final String SERVER_ADDRESS = "http://www.3tixa.com:8086/kaiyi/";
//    public static final String SERVER_ADDRESS = "http://192.168.28.139:8080/kaiyi/";

    public static final String GET_DAY_DAY_COUPON_LIST = SERVER_ADDRESS + "mall/list.php";//天天惠
    public static final String GET_DAY_DAY_COUPON_SHOW = SERVER_ADDRESS + "mall/show.php";
    public static final String GET_AUCTION_LIST_ADDRESS = SERVER_ADDRESS + "group/list.php"; //拍拍乐
    public static final String GET_DAY_DAY_COUPON_BUY = SERVER_ADDRESS + "mall/buy.php";
    public static final String POST_DAY_DAY_COUPON_CART = SERVER_ADDRESS + "mall/cart.php";
    public static final String GET_PLAY_DETAIL_ADDRESS = SERVER_ADDRESS + "store/show.php";
    public static final String GET_SECOND_HAND_CAR_LIST = SERVER_ADDRESS + "sell/list.php";//二手车
    public static final String GET_SECOND_HAND_CAR_SEARCH = SERVER_ADDRESS + "sell/search.php";
    public static final String Get_SECOND_HAND_CAR_SHOW = SERVER_ADDRESS + "sell/show.php";
    public static final String GET_SECOND_HAND_HOUSE_LIST = SERVER_ADDRESS + "sellhouse/list.php";//二手房
    public static final String GET_SECOND_HAND_HOUSE_SEARCH = SERVER_ADDRESS + "sellhouse/search.php";
    public static final String GET_SECOND_HAND_HOUSE_SHOW = SERVER_ADDRESS + "sellhouse/show.php";
    public static final String GET_TOUT_LIST_ADDRESS = SERVER_ADDRESS + "tour/list.php";//凑队去
    public static final String GET_TOUR_SMALL_NOTE_SEARCH = SERVER_ADDRESS + "tour/search.php"; //凑对去-微记-搜索
    public static final String GET_TOUT_DETAIL_ADDRESS = SERVER_ADDRESS + "tour/show.php";//凑队去-召集发布页
    public static final String POST_TOUT_publish_ADDRESS_ = SERVER_ADDRESS + "member/my.php";//凑队去-召集发布页
    public static final String GET_TOUT_comment_ADDRESS = SERVER_ADDRESS + "extend/comment.php";//凑队去-评论
    public static final String POST_TOUT_join_ADDRESS = SERVER_ADDRESS + "tour/join.php";//凑队去-加人
    public static final String GET_MESSAGEINFO_LIST = SERVER_ADDRESS + "info/list.php";//信息矿
    public static final String GET_REGISTER = SERVER_ADDRESS + "member/register.php";//注册
    public static final String GET_LOGIN = SERVER_ADDRESS + "member/login.php";//登陆
    public static final String GET_USER_DETAIL = SERVER_ADDRESS + "member/userinfo.php";
    public static final String POST_FAVORITES_ADDRESS = SERVER_ADDRESS + "member/favorite.php"; //收藏
    public static final String POST_Favorites_USER_ADDRESS = SERVER_ADDRESS + "member/my.php"; //用户中心的收藏
    public static final String POST_PRAISE_ADDRESS = SERVER_ADDRESS + "member/praise.php"; //点赞
    public static final String GET_MESSAGEADDINFO_SHOW = SERVER_ADDRESS + "info/show.php";
    public static final String GET_AUCTION_SHOW = SERVER_ADDRESS + "group/show.php";
    public static final String POST_MYJOIN_LIST = SERVER_ADDRESS + "tour/join.php";
    public static final String GET_IDENTIFYING_CODE = SERVER_ADDRESS + "member/send.php";//获取验证吗
    public static final String VALIDATE_IDENTIFYING_CODE = SERVER_ADDRESS + "member/send.php";//验证验证码
    public static final String GET_RE_PASSWORD = SERVER_ADDRESS + "member/send.php";//修改密码
    public static final String GET_EDIT_USER_DETAIL = SERVER_ADDRESS + "member/edit.php";//用户修改
    public static final String GET_MY_TRADE = SERVER_ADDRESS + "member/trade.php";//订单查看
    public static final String GET_MY_PUBLISH = SERVER_ADDRESS + "member/my.php";
    public static final String GET_CLOSE_OR_OPEN = SERVER_ADDRESS + "member/my.php";
    public static final String GET_MY_BIDDING = SERVER_ADDRESS + "group/auction.php";
    public static final String GET_BAIDU_ADDRESS = "http://api.map.baidu.com/geosearch/v3/nearby";
    public static final String GET_JOIN_IN = SERVER_ADDRESS + "member/affiliate.php";

    /**
     * 当前上下文对象集合
     */
    private Map<String, Object> modulePath = new HashMap<String, Object>();

    public static DataCenter getInstance() {
        if (instance == null) {
            instance = new DataCenter();
        }
        return instance;
    }

    private DataCenter() {
        //测试用
        if (userLogin == null) {
            userLogin = new ArrayList<UserBean>();
        }
    }

    public void initialize(Context context) {
        DataCenter.context = context;

    }


    //req.model和前台Callback交互时的flag ;
    public static enum flag {
        REQUEST_COMMON_FAILDED,
        COMMON_REQUEST_FAILED, //通用的请求失败
        GET_DAY_DAY_COUPON_LIST_SUCCESS, GET_DAY_DAY_COUPON_LIST_FAILED,
        GET_DAY_DAY_COUPON_LIST_NO_MORE_DATA, GET_DAY_DAY_COUPON_LIST_TOP_SUCCESS, GET_DAY_DAY_COUPON_LIST_TOP_FAILED,
        SHOPPING_CAR_RESULT_DATA_SUCCESS, SHOPPING_CAR_RESULT_DATA_FAILED,
        SHOPPING_CAR_RESULT_DATA_ORDER_SUCCESS, SHOPPING_CAR_RESULT_DATA_ORDER_FAILED,
        SHOPPING_CAR_ADD_SUCESS, SHOPPING_CAR_ADD_FAILED,
        SHOPPING_CAR_DEL_SUCESS, SHOPPING_CAR_DEL_FAILED,
        SHOPPING_CAR_ADD_DEL_SUCESS, SHOPPING_CAR_ADD_DEL_FAILED,
        GET_DAY_DAY_COUPON_SHOW_SUCCESS, GET_DAY_DAY_COUPON_SHOW_FAILED,
        GET_PLAY_LIST_SUCESS, GET_PLAY_LIST_FAILED, GET_PLAY_LIST_NO_MORE_DATA, GET_PLAY_LIST_TOP_SUCCESS,
        GET_SECOND_HAND_CAR_LIST_SUCCESS, GET_SECOND_HAND_CAR_FAILED, GET_SECOND_HAND_CAR_TOP_SUCCESS, GET_SECOND_HAND_CAR_TOP_FAILED,
        GET_SECOND_HAND_HOUSE_LIST_SUCCESS, GET_SECOND_HAND_HOUSE_FAILED, GET_SECOND_HAND_HOUSE_TOP_SUCCESS, GET_SECOND_HAND_HOUSE_TOP_FAILED,
        GET_SECOND_HAND_HOUSE_SEARCH_SUCCESS, GET_TOUR_LIST_SUCCESS, GET_TOUR_LIST_FAILED, GET_TOUR_LIST_TOP__FAILED, GET_TOUR_DETAIL_SUCCESS, GET_TOUR_DETAIL_FAILED,
        POST_TOUR_PUBLISH_SUCESS, POST_TOUR_PUBLISH_FAILED,
        GET_TOUR_COMMENT_LIST_SUCESS, GET_TOUR_COMMENT_LSIT_Failed, GET_TOUR_COMMENT_LSIT_NO_MORE_DATA,
        GET_TOUR_COMMENT_ADD_SUCESS, GET_TOUR_COMMENT_ADD_FAILED,
        GET_MESSAGEINFO_SUCCESS, GET_MESSAGEINFO_FAILED, GET_MESSAGEINFO_TOP_SUCCESS, GET_MESSAGEINFO_TOP_FAILED,
        GET_SOFTVERSION_SUCCESS, GET_SOFTVERSION_FAILED,
        GET_IDENTIFYING_CODE_SUCCESS, GET_IDENTIFYING_CODE_FAILED,
        VALIDATE_IDENTIFYING_CODE_SUCCESS, VALIDATE_IDENTIFYING_CODE_FAILED,
        GET_RE_PASSWORD_SUCCESS, GET_RE_PASSWORD_FAILED,
        GET_EDIT_USER_DETAIL_SUCCESS, GET_EDIT_USER_DETAIL_FAILED,
        GET_EDIT_PASSWORD_SUCCESS, GET_EDIT_PASSWORD_FAILED,
        GET_SECOND_HOUSE_SHOW_SUCCESS, GET_SECOND_HOUSE_SHOW_FAILED,
        GET_REGISTER_SUCCESS, GET_REGISTER_FAILED,
        GET_LOGIN_SUCCESS, GET_LOGIN_FAILED,
        POST_DELETE_MESSAGE_SUCCESS, POST_DELETE_MESSAGE_FAILED,
        GET_AUCTION_SHOW_SUCCESS, GET_AUCTION_SHOW_FAILED,
        GET_AUCTION_LIST_TOP_SUCCESS, GET_AUCTION_LIST_TOP_FAILED,
        GET_AUCTION_LIST_SUCCESS, GET_AUCTION_LIST_FAILED,
        GetAddMESSAGEINFO_SUCCESS, GetAddMESSAGEINFO_FAILED, GET_MYFAVORITES_SUCCESS, GET_MYFAVORITES_FAILED, GET_MESSAGEINFO_SHOW_SUCCESS, GET_MESSAGEINFO_SHOW_FAILED, GET_USER_DETAIL_SUCCESS, GET_USER_DETAIL_FAILED,
        GET_MY_TRADE_SUCCESS, GET_MY_TRADE_FAILED,
        POST_PRAISE_SUCESS, POST_PRAISE_FAILED, GET_PLAY_SHOW_SUCCESS, GET_PLAY_SHOW_FAILED, GET_SECONDCAR_SHOW_SUCCESS, GET_SECONDCAR_SHOW_FAILED,
        GET_MY_PUBLISH_SUCCESS, GET_MY_PUBLISH_FAILED,
        GET_CLOSE_OR_OPEN_SUCCESS, GET_CLOSE_OR_OPEN_FAILED,
        POST_JOIN_SUCESS, POST_JOIN_FAILED,
        GET_MY_BIDDING_SUCCESS, GET_MY_BIDDING_FAILED,
        GET_MY_JOIN_SUCCESS, GET_MY_JOIN_FAILED,
        GET_JOIN_IN_SUCCESS, GET_JOIN_IN_FAILED,
        GET_JOIN_IN_People_SUCCESS, GET_JOIN_IN_PEOPLE_FAILED,
        GET_ORDER_DETAIL_SUCCESS,GET_ORDER_DETAIL_FAILED,
        GET_ORDER_DELETE_SUCCESS, GET_ORDER_DELETE_FAILED,
        GET_REGISTER_CODE_SUCCESS,GET_REGISTER_CODE_FAILED,
        GET_JOIN_CONSTACT_SUCCESS,GET_JOIN_CONSTACT_FAILED
    }

    /**
     * req.model在yes()中调用观察者的update()方法
     *
     * @param flag 回调函数的标记，用来在众观察者的update()方法中判断
     * @author wklbeta
     */
    public void callBacks(DataCenter.flag flag) {
        setChanged();
        notifyObservers(flag);
    }

    public static class Extra {
        public static final String IMAGES = "com.nostra13.example.universalimageloader.IMAGES";
        public static final String IMAGE_POSITION = "com.nostra13.example.universalimageloader.IMAGE_POSITION";
    }
}